
import React from 'react';
import SyncLoadable from '../utils/SyncLoadable.js';
const Home = SyncLoadable(() => import('../pages/admin/home'));
const Infomation = SyncLoadable(() => import('../pages/admin/infomation'));
const Article = SyncLoadable(() => import('../pages/admin/article'));
const Charts = SyncLoadable(() => import('../pages/admin/charts'));
const Log = SyncLoadable(() => import('../pages/admin/log'));
const ContentNotFound = SyncLoadable(() => import('../pages/admin/notfound'));

class LazyRouter {
    constructor(options) {
        this.router = [
            {
                name:'home',
                component:<Home></Home>
            },
            {
                name:'information',
                component:<Infomation></Infomation>
            },
            {
                name:'article',
                component:<Article></Article>
            },
            {
                name:'charts',
                component:<Charts></Charts>
            },
            {
                name:'log',
                component:<Log></Log>
            }
        ];
    }
    getComponent(routePath) {
        let router = this.router;
        for (let i=0; i<router.length; i++) {
            if(routePath === router[i].name) {
                return router[i].component;
            }
        }
        return <ContentNotFound></ContentNotFound>;
    }
}

export default LazyRouter;